﻿using System;
using System.Collections.Generic;
using System.Drawing;
using System.Drawing.Text;
using System.Linq;
using Autodesk.Revit.DB;

namespace YJKRevitDimensionText.AnnotationSetting
{
	public class AnnotationSettingManager
	{
		public static List<Element> GetNeedElements(Autodesk.Revit.DB.Document doc, Type type)
		{
			return (from n in new FilteredElementCollector(doc).OfClass(type)
			select n).ToList<Element>();
		}

		public static List<FontFamily> GetAllTypeface()
		{
			List<FontFamily> list = new List<FontFamily>();
			foreach (FontFamily item in new InstalledFontCollection().Families)
			{
				list.Add(item);
			}
			return list;
		}

		public static string GetParaValue(Autodesk.Revit.DB.Document doc, Parameter para)
		{
            switch ((int)para.StorageType)
			{
			case 1:
				return para.AsInteger().ToString();
			case 2:
				return para.AsDouble().ToString();
			case 3:
				return para.AsString();
			case 4:
				try
				{
					return doc.GetElement(para.AsElementId()).Name;
				}
				catch
				{
					return string.Empty;
				}
				break;
			}
			return string.Empty;
		}
	}
}
